﻿using UnityEngine;
using UnityEngine.Rendering;

/// <summary>
/// 屏幕空间反射
/// </summary>
[SerializeField, VolumeComponentMenu("TheDrakKnight/ScreenSpacePlaneReflect")]
public class ScreenSpacePlaneReflectionVolume : VolumeComponent
{
    /// <summary>
    /// 是否开启屏幕空间反射
    /// </summary>
    public BoolParameter On = new BoolParameter(false);

    /// <summary>
    /// 填充黑洞，噪点
    /// </summary>
    [Tooltip("是否填充黑斑点，填充后性能更费")]
    public BoolParameter FillHoles = new BoolParameter(false);

    /// <summary>
    /// HDR
    /// </summary>
    [Tooltip("是否开启HDR，开启后RT单个通道占用翻倍（8bit到16bit）")]
    public BoolParameter HDR = new BoolParameter(false);

    /// <summary>
    /// 屏幕纹理大小
    /// </summary>
    [Tooltip("RT的大小，越大性能越费")]
    public ClampedIntParameter RTSize = new ClampedIntParameter(1024, 128, 2048, false);

    /// <summary>
    /// 反射偏移高度
    /// </summary>
    [Tooltip("反射平面的高度")]
    public FloatParameter ReflectHeight = new FloatParameter(0.2f, false);

    /// <summary>
    /// 平面淡入淡出的距离
    /// </summary>
    [Tooltip("距离屏幕边缘的衰减")]
    public ClampedFloatParameter fadeOutRange = new ClampedFloatParameter(0.3f, 0.0f, 1.0f, false);

    /// <summary>
    /// 是否开启
    /// </summary>
    /// <returns></returns>
    public bool IsActive() => On.value;

    /// <summary>
    /// 是否纹理兼容
    /// </summary>
    /// <returns></returns>
    public bool IsTileCompatible() => false;
}
